package io.hilo.example.biz01.web.demo;

import java.util.List;

import org.hilo.boot.app.web.AbstractController;
import org.hilo.boot.core.util.ValidatorUtils;
import org.jretty.apibase.Result;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.hilo.example.biz01.pojo.LoginUser;

/**
 * 系统配置信息
 */
@RestController
@RequestMapping("/sys/config")
public class ConfigController extends AbstractController {
    /**
     * 所有配置列表
     */
    @RequestMapping("/list")
    public Result<?> list(
            @RequestParam(required = false) String key, 
            @RequestParam("page") int pageNum,
            @RequestParam("limit") int pageSize) {

        // 查询列表数据
        // PagerData<ConfigEntity> list = service.selectByPage(
        // pageNum, pageSize, UT.newMap("key", key));

        return Result.success("list");
    }

    /**
     * 配置信息
     */
    @RequestMapping("/info/{id}")
    public Result<?> info(@PathVariable("id") Long id) {
        // ConfigEntity config = service.selectByPrimaryKey(id);

        return Result.success("config");
    }

    /**
     * 保存配置
     */
    @RequestMapping("/save")
    public Result<?> save(@RequestBody LoginUser config) {
        ValidatorUtils.validateEntity(config);

        // service.insert(config);

        return Result.success();
    }

    /**
     * 删除配置
     */
    @RequestMapping("/delete")
    public Result<?> delete(@RequestBody List<Long> ids) {

        // service.deleteByIds(ids);

        return Result.success();
    }

}
